package com.njbw;

import java.net.ServerSocket;

/**
 * 长沙先飞信息科技有限公司<br>
 * Created with IntelliJ IDEA.<br>
 * Date:2025/9/2<br>
 * Time:14:19<br>
 * 功能描述：<br>
 *
 * @author huang hou chun
 * @since JDK 1.8 <br>
 * Copyright (c) 2023 www.csxfrj.com System Incorporated All Rights Reserved.
 */
public class Server {

    public static void main(String[] args) throws Exception {
        // 监听指定端口
        ServerSocket ss = new ServerSocket(8888);
        System.out.println("server started at port 8888...");
        for (; ; ) {
            // 接收客户端的连接请求，accept 方法会阻塞直到有新的连接建立
            ss.accept();
            System.out.println("connected from " + ss.getInetAddress() + ":" + ss.getLocalPort());
            // 每一个连接都创建一个新的线程来处理
            new Handler(ss.accept()).start();
        }
    }
}
